package com.ss.android.newmedia.download;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;

import com.bytedance.article.common.c.TTUtils;
import com.bytedance.common.b.g;
import com.ss.android.common.app.AppHooks;
import com.ss.android.common.download.e;
import com.ss.android.common.download.h;
import com.ss.android.common.download.NotificationCompatBuilder;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.common.util.ToolUtils;
import com.ss.android.newmedia.BaseAppData;

import java.lang.ref.WeakReference;

public class a implements h {
    private static volatile a a;
    private static boolean b;

    static {
        a.a = null;
        a.b = false;
    }

    private a(Context arg3) {

        new WeakReference(arg3.getApplicationContext());
    }

    public static void a(boolean arg0) {
        com.ss.android.newmedia.download.a.b = arg0;
    }

    public final void a(AlarmManager arg2, int arg3, long arg4, PendingIntent arg6) {
        g.a(arg2, arg3, arg4, arg6);
    }

    public final boolean a() {
        return BaseAppData.inst().allowInsideDownloadManager();
    }

    public final boolean a(Context arg2) {
        return NetworkUtils.isNetworkAvailable(arg2);
    }

    public final boolean a(Context arg2, String arg3) {
        return ToolUtils.d(arg2, arg3);
    }

    public final boolean a(Context arg2, String arg3, String arg4) {
        return ToolUtils.b(arg2, arg3, arg4);
    }

    public final boolean b() {
        boolean v0 = !a.b ? true : false;
        return v0;
    }

    public final boolean b(Context arg2) {
        return BaseAppData.o(arg2);
    }

    public final boolean b(Context arg2, String arg3) {
        return ToolUtils.isAppInstalled(arg2, arg3);
    }

    public final e c(Context arg2) {
        return new e(arg2);
    }

    public final NotificationCompatBuilder d(Context arg2) {
        return new NotificationCompatBuilder(arg2);
    }

    public final boolean e(Context arg2) {
        return TTUtils.c(arg2);
    }

    public final void f(Context arg2) {
        try {
            AppHooks.InitHook v0_1 = AppHooks.getInitHook();
            if (v0_1 == null) {
                return;
            }

            v0_1.tryInit(arg2);
        } catch (Throwable v0) {
        }
    }

    public static a g(Context arg2) {
        if (a.a == null) {
            Class v1 = a.class;
            synchronized (v1) {
                if (a.a == null) {
                    a.a = new a(arg2);
                }
            }
        }

        return a.a;
    }
}

